package test8;

import java.awt.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class test8_2_1 {
	public static void main(String[] args){
		Map<String,Integer> map=new HashMap<String,Integer>();
		//Set<String> set=new TreeSet<String>();
		Scanner sr=new Scanner(System.in);
		//String[] a=words.toArray();
		while(true){
			String a=sr.next();
			//set.add(a);
			if(a.equals("!!!!!"))
				break;
			else if(!map.containsKey(a)){
					map.put(a,1);
					//set.add(a);
				}
			else {
					int num=map.get(a);
					map.put(a,++num);
				}					
			
		}
		ArrayList<Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {

            @Override
            public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
                if (o1.getValue() == o2.getValue()) {
                    return o1.getKey().compareTo(o2.getKey());
                }
                return o2.getValue() - o1.getValue();
            }

        });
	
        System.out.println(map.size());
		for(int i=0;i<10;i++){
			Map.Entry<String,Integer> e=list.get(i);
			System.out.println(e.getKey()+ "=" +e.getValue());
		}
		
		//for(Map.Entry<String, Integer> e: map){
			
		//}
			//Map.Entry<String,Integer> e=list.get(i);
			//System.out.println(e.getKey()+ "=" +e.getValue());
	}
	

}
